From 6cfc86805ad2495ef2438793ccef3f297b7b42d7 Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Fri, 5 Sep 2003 09:33:55 +0000 Subject: [PATCH] bitkeeper revision 1.410 (3f5858837RI05aQRsQBYONi4X_g2Kw) ac_timer.c: Fix a bug in timer softirq. --- xen/common/ac_timer.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/xen/common/ac_timer.c b/xen/common/ac_timer.c index a34d8f12c7..48b0aea7b9 100644 --- a/xen/common/ac_timer.c +++ b/xen/common/ac_timer.c @@ -277,30 +277,32 @@ static void ac_timer_softirq_action(struct softirq_action *a) unsigned long flags; struct ac_timer *t; struct list_head *tlist; + int process_timer_list = 0; spin_lock_irqsave(&ac_timers[cpu].lock, flags); tlist = &ac_timers[cpu].timers; if ( list_empty(tlist) ) { + /* No deadline to program the timer with.*/ reprogram_ac_timer((s_time_t)0); - spin_unlock_irqrestore(&ac_timers[cpu].lock, flags); - return; } - - t = list_entry(tlist, struct ac_timer, timer_list); - - if ( (t->expires < (NOW() + TIMER_SLOP)) || - !reprogram_ac_timer(t->expires) ) + else { /* - * Timer handler needs protecting from local APIC interrupts, but takes - * the spinlock itself, so we release that before calling in. + * Reprogram timer with earliest deadline. If that has already passed + * then we will process the timer list as soon as we release the lock. */ - spin_unlock(&ac_timers[cpu].lock); - do_ac_timer(); - local_irq_restore(flags); + t = list_entry(tlist, struct ac_timer, timer_list); + if ( (t->expires < (NOW() + TIMER_SLOP)) || + !reprogram_ac_timer(t->expires) ) + process_timer_list = 1; } + + spin_unlock_irqrestore(&ac_timers[cpu].lock, flags); + + if ( process_timer_list ) + do_ac_timer(); } -- 2.30.2